//
//  MyShoppingList_ViewController.m
//  DA_V
//
//  Created by 中亿世联前台 on 15/4/22.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "MyShoppingList_ViewController.h"
#import "ConfirmShopingListViewController.h"
#import "ShoppingListAddressView.h"
#import "ShoppingImageView.h"
#import "ShoppingImageScrollView.h"
#import "PaymentValuatioTableViewCell.h"
#import "UIViewAdditions.h"
#import "AllPraceViw.h"
#import "InterFace.h"

@interface MyShoppingList_ViewController ()

@property (nonatomic, strong) UITableView  *mytableView ;
@property (nonatomic, strong) ShoppingListAddressView *addressView;
@property (nonatomic, strong) ShoppingImageScrollView *shoppingScrollView;
@end

@implementation MyShoppingList_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    title.textAlignment = NSTextAlignmentCenter;
    title.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    title.text = @"支付";
    title.textColor = [UIColor whiteColor];
    self.navigationItem.titleView = title;
    
    [self createTableView];
    [self creareAddressView];
}

#pragma -mark 添加地址View

- (void)creareAddressView{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 340)];
//    view.backgroundColor = [UIColor redColor];
    self.addressView = [[[NSBundle mainBundle] loadNibNamed:@"Shopping_Cart_Xib" owner:self options:nil] objectAtIndex:3];
    _addressView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 156);
    [view addSubview:_addressView];
    
    //创建滑动商品图片
    CGRect rect = CGRectMake(0, self.addressView.bottom , SCREEN_WIDTH, 120);
    self.shoppingScrollView = [ShoppingImageScrollView  soppingImageScrollViewWithFrame:rect data:nil];
    
    self.shoppingScrollView.contentSize = CGSizeMake(SCREEN_WIDTH*2, 120);
    [view addSubview:self.shoppingScrollView];
    
    //线条
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(10, self.shoppingScrollView.bottom+10, SCREEN_WIDTH-20, 1)];
    lineView.backgroundColor = LineColor;
    [view addSubview:lineView];
    
    
    UIView *allPraceView = (AllPraceViw *)[[[NSBundle mainBundle] loadNibNamed:@"Shopping_Cart_Xib" owner:self options:nil] objectAtIndex:8];
    
    allPraceView.frame = CGRectMake(0, lineView.bottom+5, SCREEN_WIDTH, 60);
    [view addSubview:allPraceView];
    self.mytableView.tableHeaderView = view;
    
    
}

#pragma -mark 创建商品滑动图片
- (void)createShoppingScrollViewImage{
    CGRect rect = CGRectMake(0, self.addressView.bottom , SCREEN_WIDTH, 154);
    self.shoppingScrollView = [ShoppingImageScrollView  soppingImageScrollViewWithFrame:rect data:nil];
    //    self.shoppingScrollView.backgroundColor = [UIColor blueColor];
    self.shoppingScrollView.contentSize = CGSizeMake(SCREEN_WIDTH*2, 154);
    [self.view addSubview:_shoppingScrollView];
    
}

#pragma mark 创建tableView

- (void)createTableView{
    
    self.mytableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    self.mytableView.dataSource = self;
    self.mytableView.delegate = self;
    [self.view addSubview:self.mytableView];
}






#pragma -mark 点击确认按钮事件
- (void)okbutclick:(id)sender{
    ConfirmShopingListViewController *confirmVc = [[ConfirmShopingListViewController alloc] init];
    [self.navigationController pushViewController:confirmVc animated:YES];
}

#pragma -mark section的head高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 30;
}

#pragma -mark section的foot高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 50;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view  = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
        view.backgroundColor = [UIColor whiteColor];
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 100, 30)];
    title.text = @"支付方式";
    [view addSubview:title];
    return view;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view  = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
        //    view.backgroundColor = [UIColor greenColor];
    UIButton *goZhiFu = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, (SCREEN_WIDTH-30)/2.0, 40)];
    [goZhiFu setBackgroundImage:[UIImage imageNamed:@"支付在线支付-客户_09"] forState:UIControlStateNormal];
    [view addSubview:goZhiFu];
    
    UIButton *backBut = [[UIButton alloc] initWithFrame:CGRectMake(goZhiFu.right+10, 10, (SCREEN_WIDTH-30)/2.0, 40)];
    [backBut setBackgroundImage:[UIImage imageNamed:@"支付在线支付-客户_11"] forState:UIControlStateNormal];
    [view addSubview:backBut];
    
    
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 54;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 2;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *indentCell = @"PaymentValuatioTableViewCell";
    PaymentValuatioTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentCell];
    if (cell == nil) {
        cell =[[[NSBundle mainBundle] loadNibNamed:@"Shopping_Cart_Xib" owner:self options:nil] objectAtIndex:7];
    }
    return cell;
}


@end
